<template>
    <div>
        <el-row>
            <el-col :span="4" :offset="10">
                <span style="font-size: 32px">支付订单</span>
            </el-col>
        </el-row>

        <el-row style="text-align: left;font-size: 16px;margin-top: 30px;">
            <el-col >
                <el-row>
                    <el-col :span="4" :offset="10">收货地址：{{ order.address }}</el-col>
                </el-row>

                <el-row>
                    <el-col :span="4" :offset="10">订单编号：{{ order.orderno }}</el-col>
                </el-row>

                <el-row>
                    <el-col :span="4" :offset="10">订单金额：{{ order.totalmoney }}&nbsp;元</el-col>
                </el-row>

                <el-row>
                    <el-col :span="4" :offset="10">下单时间：{{ order.ordertime }}</el-col>
                </el-row>
                <el-row>
                    <el-col :span="4" :offset="10">订单状态：{{ orderState() }}</el-col>
                </el-row>

            </el-col>
        </el-row>



        <el-row style="margin-top: 20px;">
            <el-col :span="2" :offset="11">
                <el-button type="danger" @click="payNow()">立即支付</el-button>
            </el-col>
        </el-row>



    </div>

</template>

<script>

export default{
    data(){
        return{
            order:JSON.parse(sessionStorage.getItem("order_pay"))
        }
    },
    methods:{
        orderState(){
            console.log(this.order)
            if(this.order.status==4){
                return "未支付"
            }else{
                return "已支付"
            }
        },
        payNow(){
            this.$axios.post("/pay/now",this.order).then(respData=>{
                //返回的是一个javascript字符串，通过document.write将其写到页面上
               console.log(respData)          
               document.write(respData.data.data)
               this.$axios.put("/order/updateStatus/"+this.order.id).then(
                console.log(respData)
               )
            })
        }
    }

}

</script>

<style scoped>

</style>